home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / portage / bin / ebuild < prev    next >
Encoding:
Text File  |  2006-06-30  |  2.7 KB  |  98 lines

  1. #!/usr/bin/python -O
  2. # Copyright 1999-2006 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. # $Header: /var/cvsroot/gentoo-src/portage/bin/ebuild,v 1.18.2.3 2005/05/07 04:32:59 ferringb Exp $
  5.  
  6. import getopt, os, sys
  7.  
  8. if len(sys.argv) <= 2:
  9.     print "Usage: ebuild <ebuild file> <command> [command] ..."
  10.     print ""
  11.     print "See the ebuild(1) man page for more info"
  12.     sys.exit(1)
  13.  
  14.  
  15. (opts, pargs) = getopt.getopt(sys.argv[1:], '', ['debug'])
  16. debug = ("--debug",'') in opts
  17.  
  18.  
  19. if "merge" in pargs:
  20.     print "Disabling noauto in features... merge disables it. (qmerge doesn't)"
  21.     os.environ["FEATURES"] = os.environ.get("FEATURES", "") + " -noauto"
  22.  
  23. os.environ["PORTAGE_CALLER"]="ebuild"
  24. sys.path = ["/usr/lib/portage/pym"]+sys.path
  25.  
  26. import portage, portage_util, portage_const
  27.  
  28. # do this _after_ 'import portage' to prevent unnecessary tracing
  29. if debug and "python-trace" in portage.features:
  30.     import portage_debug
  31.     portage_debug.set_trace(True)
  32.  
  33. if portage.settings["NOCOLOR"] in ("yes","true") or not sys.stdout.isatty():
  34.     import output
  35.     output.nocolor()
  36.  
  37. ebuild = os.path.realpath(pargs.pop(0))
  38.  
  39. if not os.path.exists(ebuild):
  40.     print "'%s' does not exist." % ebuild
  41.     sys.exit(1)
  42.  
  43. ebuild_split = ebuild.split("/")
  44. del ebuild_split[-2]
  45. cpv = "/".join(ebuild_split[-2:])[:-7]
  46.  
  47. if not portage.catpkgsplit(cpv):
  48.     print "!!! %s does not follow correct package syntax." % (cpv)
  49.     sys.exit(1)
  50.  
  51. if ebuild.startswith(portage.root + portage_const.VDB_PATH):
  52.     mytree = "vartree"
  53.  
  54.     portage_ebuild = portage.db[portage.root][mytree].dbapi.findname(cpv)
  55.  
  56.     if os.path.realpath(portage_ebuild) != ebuild:
  57.         print "!!! Portage seems to think that %s is at %s" % (cpv, portage_ebuild)
  58.         sys.exit(1)
  59.  
  60. else:
  61.     mytree = "porttree"
  62.  
  63.     portage_ebuild = portage.portdb.findname(cpv)
  64.  
  65.     if not portage_ebuild or os.path.realpath(portage_ebuild) != ebuild:
  66.         overlay = "/".join(ebuild_split[:-2])
  67.         os.environ["PORTDIR_OVERLAY"] = os.environ.get("PORTDIR_OVERLAY","") + " " + overlay
  68.         print "Appending %s to PORTDIR_OVERLAY..." % overlay
  69.  
  70.         reload(portage)
  71.         portage_ebuild = portage.portdb.findname(cpv)
  72.  
  73.         if not portage_ebuild or os.path.realpath(portage_ebuild) != ebuild:
  74.             print "!!! %s does not seem to have a valid PORTDIR structure." % overlay
  75.             sys.exit(1)
  76.  
  77.  
  78. if len(pargs) > 1 and "config" in pargs:
  79.     print "config must be called on it's own, not combined with any other phase"
  80.     sys.exit(1)
  81.  
  82.  
  83. for arg in pargs:
  84.     try:
  85.         tmpsettings = portage.config(clone=portage.settings)
  86.         a = portage.doebuild(ebuild, arg, portage.root, tmpsettings, debug=debug, cleanup=("noauto" not in portage.features), tree=mytree)
  87.     except KeyboardInterrupt:
  88.         print "Interrupted."
  89.         a = 1
  90.     except KeyError:
  91.         # aux_get error
  92.         a = 1
  93.     if a == None:
  94.         print "Could not run the required binary?"
  95.         a = 127
  96.     if a:
  97.         sys.exit(a)
  98.